package com.ruoyi.web.controller.production.regulator;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.regulator.RegulatorAmount;
import com.ruoyi.production.service.regulator.IRegulatorAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调节剂量Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/regulatorAmount")
public class RegulatorAmountController extends BaseController
{
    @Autowired
    private IRegulatorAmountService regulatorAmountService;

    /**
     * 查询调节剂量列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(RegulatorAmount regulatorAmount)
    {
        startPage();
        List<RegulatorAmount> list = regulatorAmountService.selectRegulatorAmountList(regulatorAmount);
        return getDataTable(list);
    }

    /**
     * 导出调节剂量列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:export')")
    @Log(title = "调节剂量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RegulatorAmount regulatorAmount)
    {
        List<RegulatorAmount> list = regulatorAmountService.selectRegulatorAmountList(regulatorAmount);
        ExcelUtil<RegulatorAmount> util = new ExcelUtil<RegulatorAmount>(RegulatorAmount.class);
        return util.exportExcel(list, "调节剂量数据");
    }

    /**
     * 获取调节剂量详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:query')")
    @GetMapping(value = "/{regulatorAmountId}")
    public AjaxResult getInfo(@PathVariable("regulatorAmountId") Long regulatorAmountId)
    {
        return AjaxResult.success(regulatorAmountService.selectRegulatorAmountById(regulatorAmountId));
    }

    /**
     * 新增调节剂量
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:add')")
    @Log(title = "调节剂量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody RegulatorAmount regulatorAmount)
    {
        return toAjax(regulatorAmountService.insertRegulatorAmount(regulatorAmount));
    }

    /**
     * 修改调节剂量
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:edit')")
    @Log(title = "调节剂量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody RegulatorAmount regulatorAmount)
    {
        return toAjax(regulatorAmountService.updateRegulatorAmount(regulatorAmount));
    }

    /**
     * 删除调节剂量
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorAmount:remove')")
    @Log(title = "调节剂量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regulatorAmountIds}")
    public AjaxResult remove(@PathVariable Long[] regulatorAmountIds)
    {
        return toAjax(regulatorAmountService.deleteRegulatorAmountByIds(regulatorAmountIds));
    }
}
